<?php
namespace YzPay\Controller\Admin;
//use Think\Controller;
class IndexController extends CommonController {
	public function _initialize() {
		parent::_initialize();

	}

	/******提现列表****/
	public function index() {
		$this->display();
	}

	public function paySetList() {
		$this->data = BoxModel("yz_payset")->get();
		$this->display();
	}

	public function paySet() {
		$name = I('name');
		$data = BoxModel("yz_payset")->where(array('name' => $name))->find();
		if ($data) {
			$data['paySet'] = json_decode($data['paySet'], true);
			$this->type = "string";
			if (is_array($data['paySet'])) {
				$data['paySet'] = arrayeval($data['paySet']);
			}
			$this->data = $data;
		}
		if (IS_POST) {
			$name = I('name');
			$value_str = str_replace("Array", "array", stripslashes(htmlspecialchars_decode($_POST['paySet'])));
			if (strpos($value_str, "array") !== 0) {
				$value_str = "'" . $value_str . "'";
			}
			eval("\$value = " . $value_str . "; ");
			$row = array(
				'name' => $name,
				'remark' => I('remark'),
				'paySet' => json_encode($value),
			);
			if ($this->data) {
				BoxModel("yz_payset")->where(array('name' => $name))->save($row);
			} else {
				$row['store_id'] = $this->admin_store_id;
				BoxModel("yz_payset")->add($row);
			}

			$this->jump("保存成功", U('paySet', array('name' => $name)));
		}
		$this->display();
	}

}